export function setCustomSeoInfo() {
  const route = useRoute()
  const metas = []
  const links = []

  const metaObj = usePickBy(usePick(route.meta, ['title', 'description', 'keywords', 'og:image', 'og:width', 'og:height', 'og:type']), (e) => {
    return (typeof e === 'string' && e !== '') || typeof e === 'number'
  }) as Record<string, string>

  for (const key in metaObj) {
    if (key.startsWith('og:')) {
      metas.push({ property: key, content: metaObj[key] })
    }
    else {
      if (key === 'title') {
        useHead({ title: metaObj[key] })
      }
      else {
        metas.push({ name: key, content: metaObj[key] })
      }
      metas.push({ property: `og:${key}`, content: metaObj[key] })
    }
  }

  metas.push({ name: 'applicable-device', content: isPhone() ? 'mobile' : 'pc' })

  let href = ''
  if (route.name === 'blog') {
    href = import.meta.env.VITE_BLOG_HOST + route.path
  }
  else {
    href = import.meta.env.VITE_HOST + route.path
  }

  links.push({ rel: 'canonical', href })
  metas.push({ property: 'og:url', content: href })

  useHead({ meta: metas, link: links })// 使用自定义TDK，同其它地方有 useSeoMeta 会被覆盖
}
